package com.jsg.sl651.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 消息方向
 */
@AllArgsConstructor
@Getter
public enum MessageDirection {
    UP(0b0000,"上行报文"),
    DOWN(0b1000,"下行报文"),
    UNKNOWN(0b1111,"未知");
    ;
    private final int code;
    private final String desc;

    public static MessageDirection getMessageDirection(int code) {
        for (MessageDirection messageDirection : MessageDirection.values()) {
            if (messageDirection.getCode() == code) {
                return messageDirection;
            }
        }
        return UNKNOWN;
    }
}
